package xyz.zdsoft.project_group_manage_module.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.zdsoft.common.utils.Result;
import xyz.zdsoft.project_group_manage_module.service.UpdateStudentToTeamService;
import javax.annotation.Resource;
import java.util.HashMap;

@RestController
@Api(tags = "项目组管理")
public class AdminUpdateStudentToTeamController {
    @Resource
    private UpdateStudentToTeamService updateStudentToTeamService;
    @ApiOperation("学员更换小组")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "teamId",value = "项目组id",example = "1",required = true),
            @ApiImplicitParam(name = "studentId",value = "学生id",example = "1",required = true)
    })
    @PostMapping("/UpdateStudentToTeam")
    public Result updateStudentToTeam(Long teamId,Long studentId){
        HashMap<String,Object> map=new HashMap<>();
        map.put("teamId",teamId);
        map.put("studentId",studentId);

        if (updateStudentToTeamService.selHaveTeam((Long) map.get("teamId"))>0){
            if (updateStudentToTeamService.updateStudentToTeam(map)>0){
                return Result.ok().message("更新成功");
            }
            else return Result.error().message("更新失败");
        }
       else return Result.error().message("项目组不存在!");

    }

}
